<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%--
    This file is an entry point for JavaServer Faces application.
--%>
<f:view>
    <html>
        <head>
            <link rel="stylesheet" type="text/css" href="/NamibiaMedicalControl/style.css" title="Variant Stream" media="screen,projection" >
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title><h:outputText value="Cartella clinica"/></title>
        </head>
        <body>

            <div id="wrapper">
                <div id="logo">
                    <h1>Namibia medical control</h1>
                    <p><h:outputText value="#{msg.sottotitolo}"/></p>
                </div>
                <hr>
                <!-- end #logo -->
                <div id="header">
                    <div id="menu">
                        <ul>
                            <li><a href="/NamibiaMedicalControl/faces/home.jsp" class="first" >Home</a></li>           
                        </ul>
                    </div>
                    <!-- end #menu -->
                    <div id="search">
                        <div id="search-text">
                            <h:panelGroup rendered="#{loginBean.subview != null}">
                                <jsp:include page="${loginBean.subview}" />
                            </h:panelGroup>
                        </div>
                    </div>
                    <!-- end #search -->
                </div>
                <!-- end #header -->
                <!-- end #header-wrapper -->
                <div id="page">
                    <div id="page-bgtop">
                        <div id="content">
                            <div class="post">
                                <h2 class="title"><h:outputText value="Cartella clinica di #{datiPazienteBean.nome} #{datiPazienteBean.cognome}"/></h2>
                                <div class="entry">
                                    <table width="100%">
                                        <tr>
                                            <td>
                                                <a4j:form id = "foto_place">
                                                    <h:graphicImage url="/images/profile_m.gif" width="160px" height="160px" rendered="#{datiPazienteBean.foto==null && datiPazienteBean.sesso =='M' && !datiPazienteBean.renderMap}"/>
                                                    <h:graphicImage url="/images/profile_f.gif" width="160px" height="160px" rendered="#{datiPazienteBean.foto==null && datiPazienteBean.sesso =='F' && !datiPazienteBean.renderMap}"/>
                                                    <h:graphicImage url="#{datiPazienteBean.foto}" width="160px" height="160px" rendered="#{datiPazienteBean.foto!=null && !datiPazienteBean.renderMap}"/>
                                                    <a4j:keepAlive beanName="datiPazienteBean"/>
                                                    <h:panelGroup id ="map">
                                                        <rich:gmap lat="#{datiPazienteBean.latitudine}" lng="#{datiPazienteBean.longitudine}" 
                                                                   zoom="11"
                                                                   mapType="G_NORMAL_MAP"
                                                                   showGLargeMapControl="false"
                                                                   showGMapTypeControl="false"
                                                                   showGScaleControl="false"
                                                                   enableContinuousZoom="false"
                                                                   enableDoubleClickZoom="false"
                                                                   enableDragging="false"
                                                                   enableInfoWindow="false"
                                                                   rendered="#{datiPazienteBean.renderMap}"
                                                                   gmapKey="AIzaSyCCkv_fqbZw-4pZPl5bTUJ22mRaAKhKU48"
                                                                   />
                                                    </h:panelGroup>
                                                    <br>
                                                    <h:commandButton action="#{datiPazienteBean.toggleMap}" disabled="#{datiPazienteBean.buttonDisabled}" value="#{datiPazienteBean.buttonMessage}"/>
                                                </a4j:form>
                                            </td> 
                                            <td>
                                                <table width="100%">
                                                    <tr>
                                                        <td><b>Nome: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.nome} #{datiPazienteBean.cognome}"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>Sesso: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.sesso}"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>Data di nascita: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.dataNascita}"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>Luogo di nascita: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.luogoNascita}"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>Indirizzo: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.indirizzo}"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>CAP: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.cap}"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>E-Mail: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.email}" rendered="#{datiPazienteBean.email != null}"/>
                                                            <h:outputText value="Nessun indirizzo e-mail" rendered="#{datiPazienteBean.email == null}"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>Telefono: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.telefono}" rendered="#{datiPazienteBean.telefono != null}"/>
                                                            <h:outputText value="Nessun numero di telefono" rendered="#{datiPazienteBean.telefono == null}"/>                                      
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>Genitore: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.genitore}" rendered="#{datiPazienteBean.genitore != null}"/>
                                                            <h:outputText value="Orfano" rendered="#{datiPazienteBean.genitore == null}"/>                                      
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><b>Medico </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.medico}" />
                                                    </tr>
                                                    <tr>
                                                        <td><b>Capo villaggio: </b></td>
                                                        <td>
                                                            <h:outputText value="#{datiPazienteBean.capoVillaggio}" rendered="#{datiPazienteBean.capoVillaggio != null}"/>
                                                            <h:outputText value="Sono io il capovillaggio!AUGH!" rendered="#{datiPazienteBean.capoVillaggio == null}"/>                                      
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                            <div class="post">
                                <h2 class="title"><h:outputText value="Visite"/></h2>
                                <p class="meta">Puoi visualizzare i tuoi dati, ma per modificarli devi recarti all'usl e fare richiesta</p>
                                <div class="entry">
                                    <a4j:form>
                                        <rich:dataTable id="visite"
                                                        value="#{datiPazienteBean.listCartella()}"
                                                        var="result"
                                                        width="500px"
                                                        columnClasses="center"
                                                        rows="10">
                                            <f:facet name="header">
                                                <rich:datascroller for="visite"/>          
                                            </f:facet>
                                            <rich:column>
                                                <f:facet name="header">
                                                    <h:outputText value="Data"/>
                                                </f:facet>
                                                <h:outputText value="#{result.data}"/>
                                            </rich:column>
                                            <rich:column>
                                                <f:facet name="header">
                                                    <h:outputText value="Tipo"/>
                                                </f:facet>
                                                <h:outputText value="#{result.tipo}"/>
                                            </rich:column>
                                            <rich:column>
                                                <f:facet name="header">
                                                    <h:outputText value="Descrizione"/>
                                                </f:facet>
                                                <h:outputText value="#{result.descrizione}"/>
                                            </rich:column>
                                            <rich:column>
                                                <f:facet name="header">
                                                    <h:outputText value="Richiami"/>
                                                </f:facet>
                                                <h:outputText value="#{result.richiami}"/>
                                            </rich:column>
                                            <f:facet name="footer">
                                                <rich:datascroller for="visite"/>
                                            </f:facet>
                                        </rich:dataTable>
                                    </a4j:form>
                                </div>

                            </div>
                        </div>
                        <!-- end #content -->
                        <div id="sidebar">
                            <ul>
                                <li>
                                    <jsp:include page="../subviews/language_chooser.jsp"/>
                                </li>
                                <li>
                                    <jsp:include page="../subviews/side_reserved_menu.jsp"/>
                                </li>
                            </ul>
                        </div>
                        <!-- end #sidebar -->
                        <div style="clear: both;">&nbsp;</div>
                    </div>
                </div>
                <!-- end #page -->
                <div id="footer-bgcontent">
                    <div id="footer">
                        <p>Copyright &copy; 2011 <a href="#">Mamesoft</a>
                            Progetto Programmazione per il web A.A.2011/2012</p>
                    </div>
                </div>
                <!-- end #footer -->
            </div>
        </body>
    </html>
</f:view>